package danebrown;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class XlsxWriter {
    private static ExcelWriter excelWriter;
    public static void write(String fileName, String sheetName, List<List<String>> data) {
        if (!Files.exists(Paths.get(fileName))) {
            excelWriter = EasyExcel.write(fileName).build();
        }
        WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).build();
        excelWriter.write(data, writeSheet);
    }
    public static void finish(){
        excelWriter.finish();
    }
}
